package com.ceshiren.chnjx.wework.page.contact;

import com.ceshiren.chnjx.wework.page.BasePage;
import com.ceshiren.chnjx.wework.utils.CustomStrUtils;
import io.appium.java_client.AppiumDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

/**
 * @author JJJJ
 * @Title:
 * @date 2021/11/8下午9:25
 * @Description:
 */
public class EditMemberPage extends BasePage {
    private By nameInput = By.xpath("//*[@id='f72']//*[@id='ber']");
    private By phoneInput = By.xpath("//*[@id='f7g']//*[@id='ber']");
    private By deleteMemberBtn =  By.xpath("//*[@text='删除成员']");
    private By confirmBtn = By.xpath("//*[@text='确定']");
    private By saveBtn = By.xpath("//*[@text='保存']");
    public EditMemberPage(AppiumDriver driver) {
        super(driver);
    }

    /**
     * 删除成员
     */
    public ContactPage deleteMember(){
        click(deleteMemberBtn).click(confirmBtn);
        return new ContactPage(driver);
    }

    public ContactPage editMember(String newName, String newPhone) {
        if (!CustomStrUtils.isEmpty(newName)){
            sendDate(nameInput,newName);
        }
        if (!CustomStrUtils.isEmpty(newPhone)){
            sendDate(phoneInput,newPhone);
        }
        click(saveBtn);
        return new ContactPage(driver);
    }
}
